#include<bits/stdc++.h>
#define mid (l+r>>1)
#define rs (k<<1|1)
#define ls (k<<1)
using namespace std;
const int N=1e6+5;
int n,q;
char a[N];
vector<int> qu[N];
int nd;
int md;
int la[N*2];
struct node{
    int lz;
    int def;
    int s;
}t[N<<2];
void pushdown(int k){
    if(t[ls].def<t[k].lz){
        t[ls].s+=t[k].lz-t[ls].def;
        t[ls].def=0;
    }
    else t[ls].def-=t[k].lz;
    t[ls].lz+=t[k].lz;
    if(t[rs].def<t[k].lz){
        t[rs].s+=t[k].lz-t[rs].def;
        t[rs].def=0;
    }
    else t[rs].def-=t[k].lz;
    t[rs].lz+=t[k].lz;
    t[ls].def+=t[k].def;
    t[rs].def+=t[k].def;
    t[k].def=t[k].lz=0;
}
void updated(int l,int r,int k,int x,int y){
    if(x>y)return;
    if(x<=l&&r<=y){
        t[k].def++;
        return;
    }
    pushdown(k);
    if(x<=mid)updated(l,mid,ls,x,y);
    if(y>mid)updated(mid+1,r,rs,x,y);
}
void updates(int l,int r,int k,int x,int y){
    if(x>y)return;
    if(x<=l&&r<=y){
        if(t[k].def)t[k].def--;
        else{
            t[k].s++;
            t[k].lz++;
        }
        return;
    }
    pushdown(k);
    if(x<=mid)updates(l,mid,ls,x,y);
    if(y>mid)updates(mid+1,r,rs,x,y);
}
int query(int l,int r,int k,int x){
    if(l==r)return t[k].s;
    pushdown(k);
    if(x<=mid)return query(l,mid,ls,x);
    return query(mid+1,r,rs,x);
}
vector<int> v;
int ans;
int main(){
    freopen("good.in","r",stdin);
    freopen("good.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>q;
    cin>>a+1;
    while(q--){
        int l,r;
        cin>>l>>r;
        qu[l].push_back(r);
    }
    for(int i=0;i<=2*n;++i)la[i]=n+2;
    for(int i=n;i;--i){
        if(a[i]=='1'){
            if(md){
                //cout<<v.back()<<' '<<n<<" -1\n";
                updates(1,n,1,v.back(),n);
                v.pop_back();
            }
            md=max(md-1,0);
            nd++;
            la[n+nd]=i;
        }
        else{
            ++md;
            nd--;
            updates(1,n,1,i,la[n+nd]-2);
            //cout<<i<<' '<<la[n+nd]-2<<" -1\n";
            la[n+nd]=i;
            updated(1,n,1,i,n);
            //cout<<i<<' '<<n<<" +1\n";
            v.push_back(i);
        }
        for(auto qq:qu[i]){
            int l=0,r=v.size();
            while(l<r){
                if(v[mid]>qq)l=mid+1;
                else r=mid;
            }
            int s=v.size()-l;
            //cout<<s<<'\n';
            s+=query(1,n,1,qq);
            //cout<<i<<' '<<qq<<' '<<s<<'\n';
            ans^=s;
        }
    }
    cout<<ans;
    return 0;
}
